package com.gsj.system.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gsj.common.pojo.R;
import com.gsj.system.eneity.Log;
import com.gsj.system.mapper.LogMapper;
import com.gsj.system.pojo.LogVo;
import com.gsj.system.service.LogService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: clmseighth
 * @description:
 * @author: 张巍蓝
 * @create: 2021-07-25 14:17
 **/
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public R queryAllLog(Integer currentPage, Integer pageSize, LogVo logVo) {
        Page<Log> objectPage = new Page<>(currentPage, pageSize);
        QueryWrapper<Log> logQueryWrapper = new QueryWrapper<>();
        if(StringUtils.isNotEmpty(logVo.getTitle())){
            logQueryWrapper.like("title",logVo.getTitle());
        }
        Page<Log> logPage = logMapper.selectPage(objectPage, logQueryWrapper);
        return R.ok().put("allLog",logPage.getRecords()).put("total",logPage.getTotal());
    }

    @Override
    public R deleteLogById(Integer id) {
        logMapper.deleteLogById(id);
        return null;
    }
}
